package cn.edu.zjgsu.ito.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;
import com.jfinal.core.Controller;

public class GlobalInterceptor implements Interceptor {

	/*
	 * 张虎涛
	 * 2016/06/01
	 */
	@Override
	public void intercept(ActionInvocation ai) {
		Controller controller = ai.getController();
		String flag=controller.getSessionAttr("flag");
		
		if (flag == null) {
			controller.setSessionAttr("flag", "0");
			System.out.println(0);
			ai.getController().redirect("/index");
			return;				
		} else {
			System.out.println(11);
			ai.invoke();
			return;
		}
		

	}

}
